'''
Created on 25.08.2012

@author: Thomas Koch
'''

import sys
#print sys.version, sys.path

def search_artist(query='solr', verb=False):
    print "searching for artist '%s' ..." % query
    from pythonsolr import Solr
    con = Solr('http://localhost:8983/solr/mbartists/')
    res = con.search(query)
    i = 0
    print "found %d" % len(res)
    for result in res:
        name = result.get('a_name','?')
        auid = result.get('id',None)
        atyp = result.get('a_type',None)
        if not atyp:
            atyp = result.get('type',None)
        print "%#d: id=%s\tname='%s'\ttype: %s" % (i,auid,name,atyp)
        if verb:
            print result
        i+=1

if __name__ == '__main__':
    print "enter text:"
    line = sys.stdin.readline()
    line = line.strip()

    search_artist(line)
